import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:riverpod_t/page/home/state/home_scroll_state.dart';
part 'home_detail_scroll_river.g.dart';

@riverpod
class HomeDetailScrollRiver extends _$HomeDetailScrollRiver {
  @override
  ScrollState build() {
    return ScrollState();
  }

  /// 改变透明度
  void updateScroll(double newOffset) {
    /// offset滚动距离
    double alpha = newOffset / 100;
    if (alpha < 0) {
      alpha = 0;
    } else if (alpha > 1) {
      alpha = 1;
    }
    state = state.copyWith(scrollOffset: newOffset, alpha: alpha);
  }
}
